<?php 

$countries = array(	'mascareneIslands',
					'madagascar',
					'comoroIslands',
					'southAfrica',
					'lesotho',
					'swaziland',
					'namibia',
					'botswana',
					'zimbabwe',
					'mozambique',
					'angola',
					'zambia',
					'malawi',
					'tanzania',
					'congo',
					'cabinda',
					'congoBrazzaville',
					'gabon',
					'equatorialGuinea',
					'burundi',
					'rwanda',
					'uganda',
					'kenya',
					'somalia',
					'ethiopia',
					'djibouti',
					'eritrea',
					'cameroon',
					'centralAfricanRepublic',
					'sudan',
					'chad',
					'egypt',
					'libya',
					'nigeria',
					'niger',
					'tunisia',
					'algeria',
					'morocco',
					'westernSahara',
					'mauritania',
					'mali',
					'burkinaFaso',
					'benin',
					'togo',
					'ghana',
					'coteDIvoire',
					'liberia',
					'sierraLeone',
					'guinea',
					'guineaBissau',
					'senegal',
					'gambia',
					'madeira',
					'canaryIslands'
					);


$__contents = 'package org.dschini.ui.maps.world.##Continent## {

	import flash.display.Sprite;
	import org.dschini.ui.maps.*;

	public class ##Country##Map extends Map
	{
		public var ##CountryToLower##MapStateLines:Sprite;
		public var ##CountryToLower##MapShape:Sprite;
		
		override public function set mouseEnabled( mouseEnabled:Boolean ):void
		{
			super.mouseEnabled = mouseEnabled;
			##CountryToLower##MapShape.mouseEnabled = mouseEnabled;
			##CountryToLower##MapStateLines.mouseEnabled = mouseEnabled;
		}
		
		override public function set doubleClickEnabled( doubleClickEnabled:Boolean ):void
		{
			super.doubleClickEnabled = doubleClickEnabled;
			##CountryToLower##MapShape.doubleClickEnabled = doubleClickEnabled;
			##CountryToLower##MapStateLines.doubleClickEnabled = doubleClickEnabled;
		}
		
		override public function render():void
		{
			##CountryToLower##MapShape.visible = data.shapeVisible ? true : false;
			if( data.shapeColorTransform ){
				##CountryToLower##MapShape.transform.colorTransform = data.shapeColorTransform;
			}
			##CountryToLower##MapStateLines.visible = data.stateLinesVisible ? true : false;
			if( data.stateLinesColorTransform ){
				##CountryToLower##MapStateLines.transform.colorTransform = data.stateLinesColorTransform;
			}
		}
	}	
}
';

$Continent = "africa";

foreach( $countries as $country ){
	$FileName = ucfirst($country).'Map.as';

	if( file_exists( $FileName ) == false ){
		$fp = fopen($FileName, 'w');
		
		$healthy = array("##Continent##", "##Country##", "##CountryToLower##");
		$yummy = array($Continent,ucfirst($country),$country);
		$Contents = str_replace($healthy, $yummy, $__contents);
		
		fwrite($fp, $Contents);
		fclose($fp);
	}

}
